#include <bits/stdc++.h>
using namespace std;
int main(){
    int length,cnt;
    int maxt=0,mint=0;
    int maxtmp=0,mintmp=0;
    int pos;
    // int testarr[] = {1,3};
    cin>>length>>cnt;
    for (int i=0;i<cnt;i++){
        cin>>pos;
        if (pos > length/2){
            mintmp = length-pos+1;
            maxtmp = pos;
        }
        else {
            mintmp = pos;
            maxtmp = length-pos+1;
        }
        if (maxtmp > maxt) maxt=maxtmp;
        if (mintmp > mint) mint=mintmp;
    }
    printf("%d %d",mint,maxt);
    return 0;
}